<template>
  <div class="header">
    <h1>我是Header</h1>
    <p>Count的值是{{ count }}+{{ price }}</p>
    <button @click="increament">每次加一</button>
    <button @click="increamentN({ n: 3,m:4 })">每次加3+4</button>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "Header",
  mounted() {
    console.log(this);
    // console.log(mapState(["count"]).count.call(this))
    // console.log(mapState(["count"]))
    console.log(mapState({ count: "count" }));
  },
  //对象中只能放对象
  computed: {
    ...mapState({
      count: "count",
      price: "price",
    }),
  },
  // computed:mapState(["count","price"])

  methods: {
    // ...mapMutations(["increament","increamentN"])
    increament() {
      this.$store.commit("increament");
    },
    increamentN({n,m}) {
      this.$store.commit("increamentN", {n,m});
    },
  },
};
</script>

<style scoped>
.header {
  margin: 30px;
  background: yellowgreen;
}
</style>